       IDENTIFICATION DIVISION.
       PROGRAM-ID. REMOVE.

       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
           SPECIAL-NAMES.
               DECIMAL-POINT IS COMMA.

       INPUT-OUTPUT SECTION.
        FILE-CONTROL.
           SELECT OPTIONAL FD-CLIENTES ASSIGN TO "CLIENTES.DAT"
               ORGANIZATION IS INDEXED
               ACCESS MODE IS DYNAMIC
               RECORD KEY IS FD-CONTA
               FILE STATUS IS WS-FD-CLIENTES-STATUS.

       DATA DIVISION.
       FILE SECTION.
       FD FD-CLIENTES.

       01 FD-CLIENTES-REG.
            02 FD-CONTA           PIC 9(006).
            02 FD-CPF             PIC 9(011).
            02 FD-NOME            PIC X(060).
            02 FD-DATA-NASC.
                03 ANO-NASC    PIC 9999.
                03 MES-NASC    PIC 99.
                03 DIA-NASC    PIC 99.
			02 FD-SALDO           PIC 9(8).
            02 FD-DATA-ABERTURA.
                03 ANO-CONTA   PIC 9999.
                03 MES-CONTA   PIC 99.
                03 DIA-CONTA   PIC 99.
            
       WORKING-STORAGE SECTION.
       01 WS-FD-CLIENTES-STATUS PIC X(2).
       01 WS-OPCAO PIC X(01) VALUE SPACES.
           88 FINALIZA VALUE "n", "N".
       01 WS-CONFIRMA PIC X(1) VALUE SPACES.
           88 WS-CANC               VALUE "N", "n".
           88 WS-OK                 VALUE "S", "s".

       PROCEDURE DIVISION.
           PERFORM 001-INICIO.
           PERFORM 002-PROCESSA UNTIL FINALIZA.
           PERFORM 005-FIM.

       001-INICIO.
           DISPLAY ERASE.
           OPEN I-O FD-CLIENTES.

          IF WS-FD-CLIENTES-STATUS NOT EQUAL "00"
             DISPLAY "ERRO " WS-FD-CLIENTES-STATUS "."
			 STOP " "
             MOVE "N" TO WS-OPCAO
          END-IF.

        002-PROCESSA.
           DISPLAY "DIGITE A CONTA PARA EXCLUSAO: ".
           ACCEPT FD-CONTA WITH PROMPT.

           READ FD-CLIENTES.

           IF WS-FD-CLIENTES-STATUS EQUALS "00"
              DISPLAY "CONTA CORRENTE: " FD-CONTA
              DISPLAY "CPF: " FD-CPF
              DISPLAY "NOME: " FD-NOME
              DISPLAY "DATA DE NASCIMENTO: " DIA-NASC "/"
            MES-NASC "/" ANO-NASC
              DISPLAY "DATA DE ABERTURA DA CONTA: " DIA-CONTA
       "/" MES-CONTA "/" ANO-CONTA
              DISPLAY "SALDO: " FD-SALDO
              DISPLAY " "
			  
              PERFORM 003-CONFIRMACAO UNTIL WS-OK OR WS-CANC
			  
              IF WS-OK
                  PERFORM 004-EXCLUI
              ELSE
                  PERFORM 005-FIM
              END-IF
           ELSE
              IF WS-FD-CLIENTES-STATUS EQUALS "23"
                  DISPLAY "ARQUIVO NAO EXISTENTE"
              ELSE
                  DISPLAY "ERRO - " WS-FD-CLIENTES-STATUS
              END-IF
           END-IF.

           DISPLAY "DESEJA CONTINUAR? [S/N] " AT 2305.
           ACCEPT WS-OPCAO AT 2330 WITH PROMPT.

       003-CONFIRMACAO.
           DISPLAY "DESEJA EXCLUIR O REGISTRO <S/N> [ ]".
           ACCEPT WS-CONFIRMA AT 2338 WITH PROMPT.
		   
       004-EXCLUI.
           DISPLAY "REGISTRO APAGADO."
           STOP " ".
           DELETE FD-CLIENTES.
	   
       005-FIM.
           CLOSE FD-CLIENTES.
           DISPLAY ERASE AT 0801.
           DISPLAY "RETORNANDO AO MENU PRINCIPAL..." AT 0805.
           STOP " ".
           GOBACK.